function CustomerCheck_Code() {
	var buffer = new StringBuffer();
	buffer.append('<div id="find" class="finds2"><div class="searchinput ui-border-radius"><input id="keyword" class="bordersolid" type="text" value="" onblur="Show_Search()" onkeyup="CustomerCheck_Search();"/><div id="searchicon" class="searchicon"><img src="img/jing.jpg"/></div><div id="searchicons" class="searchicons"><img src="img/jings.jpg"/></div></div></div>');
	buffer.append('<div class="horizen border-bottom"></div>');
	return buffer.toString();
};

function CustomerCheck_Data(data) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		buffer.append('<div class="customerlist border-bottom" id="'+info.ID+'"><div class="customername">'+info.Name+'</div><div class="customerinfo"><div class="state">'+info.State+'</div><div class="lastconntime">'+info.LastConnDate.ToTime()+'</div></div></div>');
	});
	return buffer.toString();
};

function Receive_CustomerCheck(pageindex)
{
	var data = {};
			data.act = "Find_CustomerCheck";
			data.userid=userid;
			data.comid=comid;
			data.pageindex=pageindex;
			data.source=source;
			data.pagesize=PAGE_SIZE20;
			data.keyword = $("#keyword").val();
			data.sign=GetSign(data.act);
			
			mui.getJSON(crm_domain, data, function(json) {
				if(json.data.list.length>0)
				{
					if(pageindex==1)
					{
						$("#contentlist1").html(CustomerCheck_Data(json.data.list));
					}else{
						$("#contentlist1").append(CustomerCheck_Data(json.data.list));
					}
					setTimeout(function(){
						myScroll1.refresh();
					},500); //需要延迟500毫秒加载，否则当数量少时不能下拉
					if(json.data.list.length!=data.pagesize)
					{
						$("#loading1").html("");
					}else{
						$("#loading1").html('<img src="img/loading.gif"/>');
					}
				}else
				{
					
					if(pageindex==1)
					{
						$("#contentlist1").html("");
						$("#loading1").html("主人，没有找到您需要的数据"); 
					}
					else
					{
						$("#loading1").html("没有更多了");
					}
				}
				
         		pageindex = parseInt($("#divmsg1").attr("pageindex"))+1;
         		$("#divmsg1").attr("pageindex",pageindex);
			});
};

function CustomerCheck_Search(){
	if($("#keyword").val().Trim()=="")
	{
		$("#contentlist1").html("");
		$("#loading1").html("通过客户名称查询该客户是否已存在");
	}else{
		pageindex=1;
		$("#divmsg1").attr("pageindex","0");
		Receive_CustomerCheck(1);
	}
};


